function fuzzyBill(){
    $.ajax({
        url: "/bill/fuzzyQueryBill",
        data: {'condition':$("#scText").val()},
        type: "GET",
        success: function (htmlText){
            $("#billSpace").html(htmlText)
        }
    })
}

function addBill() {
    layer.open({
        type: 2,
        title: "添加订单",
        maxmin: true,
        shadeClose: true,
        area : ['600px' , '450px'],
        content:'/bill/addBill',
        end: function () {
            location.reload()
        }
    })
}

function billDetails(id) {
    layer.open({
        type: 2,
        title: "详情",
        maxmin: true,
        skin: 'layui-layer-lan',
        shadeClose: true,
        area: ['400px' , '350px'],
        content: '/bill/billDetails?id='+id,
        end: function () {
            location.reload()
        }
    })
}

function billUpdate(id) {
    layer.open({
        type: 2,
        title: "修改订单",
        maxmin: true,
        skin: 'layui-layer-lan',
        shadeClose: true,
        area: ['600px','450px'],
        content: '/bill/updateBill?id='+id,
        end: function () {
            location.reload()
        }
    })
}

function deleteBill(id) {

    layer.confirm("确认删除吗", {icon : 3 , title : '提示'}, function (index) {
        $.post({
            url: '/bill/deleteBill',
            data: {'id':id},
            success: function (data) {
                var num = data.code==200?1:2;
                layer.msg(data.msg,{icon:num,shade:0.3,offset:'40%',time:2000,content:"正在删除"})
                setTimeout(function () {
                    location.reload()
                },1000);
            },
            error: function (jqXHR, textStatus, errorThrown) {
                if (jqXHR.status == 403){
                    layer.confirm('权限不足', {icon: 2, title:'提示'})
                } else {
                    layer.confirm('发生错误', {icon: 2, title:'提示'})
                }
            }
        })
    })

}
